<?php

/**
 * RaiseException class
 * Represents an Exception used by phpRaise
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.Exception
 * @since 1.2
 */
class RaiseException extends Exception {

    /**
     * The context of the exception
     * @var mixed
     */
    private $context;

    /**
     * Converts an exception to a RaiseException
     * @param string $message (optional) The error message related to this exception
     * @param int $code (optional) The error code related to this exception
     * @param Exception $exception (optional) The chained exception
     */
    public function __construct($message = '', $code = 0, $exception = null){
        if($exception || $message || $code){
            parent::__construct($message, $code, $exception);
        }else{
            parent::__construct();
        }
    }

    /**
     * Set the context of the Exception
     * @return mixed
     */
    public function setContext($v){
        $this->context = $v;
    }

    /**
     * Get the context of the Exception
     * @return mixed
     */
    public function getContext(){
        return $this->context;
    }

    /**
     * Set the error message
     * @param string $m
     */
    public function setMessage($m){
        $this->message = $m;
    }

    /**
     * Set the file in which the Exception was raised
     * @param string $f
     */
    public function setFile($f){
        $this->file = $f;
    }

    /**
     * Set the exception code
     * @param int $c
     */
    public function setCode($c){
        $this->code = $c;
    }

    /**
     * Set the Line number in which the error occurred in the File
     * @param int $l
     */
    public function setLine($l){
        $this->line = $l;
    }
}

